//
//  TestController.swift
//  microblog
//
//  Created by cy on 2017/8/27.
//  Copyright © 2017年 cy. All rights reserved.
//  忽略提交一些文件


import UIKit
import SnapKit


/// 测试用 -- master 分支
class TestController: BaseController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        let jsonString = "{\"age\": 20,\"height\": 167,\"weight\":112,\"sex\":\"male\",\"name\":\"young\"}"
        
        if let object = Person.deserialize(from: jsonString) {
            print(object.name, object.age, object.sex, object.height, object.weight)
        }
    }
    
    
    
    /// 跳转到 Objective-C 页面
    // FIXME: - 暂时还不能设置转场动画
    @objc fileprivate func nextPage() {
        let tabBarVC = ATLTabBarController()
        let objcVC = ObjcController()
        
        if let vcs = navigationController?.viewControllers {
            objcVC.stackControllers = []
            for vc in vcs {
                objcVC.stackControllers?.add(vc)
            }
        }
        
          
        tabBarVC.setupChildViewController(
            objcVC, title: "首页", image: "tabbar_home",
            selectedImage: "tabbar_home_selected")
        
        let objcRoot = UIApplication.shared.delegate as? AppDelegate
        objcRoot?.window?.rootViewController = tabBarVC
    }
}


// MARK: - 设置界面
extension TestController {
    
    override func setupTableView() {
        super.setupTableView()
        
        let label = UILabel()
        label.text = "😁😁😁😁😁😁😁😁😁😁😁"
        label.numberOfLines = 0
        label.textAlignment = .center
        label.backgroundColor = UIColor.orange
        view.addSubview(label)
        
        label.snp.makeConstraints { (make) in
            make.center.equalTo(self.view)
            make.width.equalTo(UIScreen.main.bounds.width * 0.5)
        }
        
    }
    
    override func setupNavBar() {
        super.setupNavBar()
        
        title = "第\(navigationController?.viewControllers.count ?? 0)个"
        
        // 设置导航栏右侧按钮
        navItem.rightBarButtonItem = UIBarButtonItem(title: "下一个", fontSize: 16, target: self, action: #selector(nextPage), isBack: false)
    }
}

